package xyz.robinbingo.leetcode.a20.b05.c09;

public class Solution {
    public static int mySqrt(int x) {
        int result = 0;
        for (long i = 0; i < x; i++) {
            long a = i * i;
            long b = (i + 1) * (i + 1);
            if (a <= x && b > x) {
                return (int) i;
            } else if (b == x) {
                return (int) (i + 1);
            }
        }
        return result;
    }
}